package com.hs.sfzy.controller;

import com.hs.sfzy.entity.CourseRating;
import com.hs.sfzy.service.CourseRatingService;
import com.hs.sfzy.until.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName CourseRatingController
 * @Description TODO
 * @Author Chen
 * @Date 2025年08月13日 15:03
 * @Version 1.0
 */
@RestController
@RequestMapping("courseRating")
public class CourseRatingController {
    @Autowired
    private CourseRatingService courseRatingService;

    @GetMapping("{courseId}")
    public R getCourseRating(@PathVariable("courseId") Integer courseId) {
        List<CourseRating> allCourseRating = courseRatingService.getAllCourseRating(courseId);
        return R.ok(allCourseRating);
    }
    @PostMapping("add")
    public R addCourseRating(@RequestBody CourseRating courseRating) {
        Integer addCourseRating = courseRatingService.addCourseRating(courseRating);
        return R.ok(addCourseRating);
    }
}
